package com.hww.acommon.test;

import com.hww.acommon.R;
import com.hww.common.MyAppThis;
import com.hww.common.util.ThreadUtils;
import com.hww.common.util.ToastUtils;
import com.hww.dialog.SweetAlertDialog;

import java.util.concurrent.ExecutorService;


/**
 * @author hww
 * @date 0017 2024/6/17
 * email: heww@zhongyuntech.cn
 * description:
 */
public class ToastActivity extends BaseActivity {

    private static final ExecutorService singlePool = ThreadUtils.getSinglePool();

    @Override
    protected void initDate() {
        updateLayout();

        setGONE();

        setBTText(binding.bt1, "error Toast");
        setBTText(binding.bt2, "Normal");
        setBTText(binding.bt3, "custom");
        setBTText(binding.bt4, "轮询所有样式");

        binding.bt1.setOnClickListener((view) -> {
            System.out.println("base64--------------------");

            ToastUtils.error(MyAppThis.getThis(), "这是一个错误提示").show();

        });
        binding.bt2.setOnClickListener((view) -> {
//            singlePool.execute(new Runnable() {
//                @Override
//                public void run() {
//                }
//            });
            ToastUtils.normal(MyAppThis.getThis(), "这是一个普通样式提示").show();
        });
        binding.bt3.setOnClickListener((view) -> {
            ToastUtils.custom(MyAppThis.getThis(), "这是一个自定义样式提示",
                    ToastUtils.getDrawable(MyAppThis.getThis(), R.mipmap.ic_launcher_round), 1, true).show();
        });
        binding.bt4.setOnClickListener((view) -> {
            ToastUtils.warning(MyAppThis.getThis(), "警告提示").show();
            ToastUtils.error(MyAppThis.getThis(), "错误提示").show();
            ToastUtils.info(MyAppThis.getThis(), "显示提示").show();
            ToastUtils.normal(MyAppThis.getThis(), "默认提示").show();
            ToastUtils.success(MyAppThis.getThis(), "成功提示").show();
            ToastUtils.custom(MyAppThis.getThis(), "自定义提示",
                    ToastUtils.getDrawable(MyAppThis.getThis(), R.drawable.one),
                    ToastUtils.LENGTH_LONG, true).show();
        });
    }

    private void mToast(String msg) {
        ToastUtils.normal(MyAppThis.getThis(), msg).show();
    }

    /**
     * @param alertType {@linkplain SweetAlertDialog#PROGRESS_TYPE}
     * @return
     */
    private SweetAlertDialog getDialog(int alertType) {
        return new SweetAlertDialog(this, alertType);
    }


}
